/***********************************************************************
	filename: 	CEGUIMouseCursor.h
	created:	21/2/2004
	author:		Paul D Turner
	
	purpose:	Defines interface for the MouseCursor class
*************************************************************************/
#ifndef _HgeMouseCursor_h_
#define _HgeMouseCursor_h_

#include "hgeSingleton.h"
#include "hgeVector.h"
#include "hgeRect.h"
#include "hgeGuiEventSet.h"
#include "hgeGuiInputEvent.h"

#include <string>

#if defined(_MSC_VER)
#	pragma warning(push)
#	pragma warning(disable : 4275)
#	pragma warning(disable : 4251)
#endif


/*!
\brief
	Enumeration of special values used for mouse cursor settings in Window objects.
*/
enum MouseCursorImage
{		
	BlankMouseCursor	= 0,		//!< No image should be displayed for the mouse cursor.
	DefaultMouseCursor	= -1		//!< The default mouse cursor image should be displayed.
};


/*!
\brief
	Class that allows access to the GUI system mouse cursor.

	The MouseCursor provides functionality to access the position and imagery of the mouse cursor / pointer
*/
class MouseCursor : public EventSet, public Singleton<MouseCursor>
{
public:
	static const String EventNamespace;				//!< Namespace for global events

	/*************************************************************************
		Event name constants
	*************************************************************************/
	// generated internally by MouseCursor
	static const String EventCursorChanged;			//!< The cursor image of the widget has changed.


	//Constructor for MouseCursor objects
	MouseCursor(void);

	//Destructor for MouseCursor objects
	~MouseCursor(void);

	//Return singleton MouseCursor object
	static	MouseCursor&	getSingleton(void);

	//Return pointer to singleton MouseCursor object
	static	MouseCursor*	getSingletonPtr(void);

	//Get the current mouse cursor image
	HCURSOR	getCursor(const String& cursorFile);

	//Point object describing the mouse cursor position in screen pixels.
	Point	getPosition(void) const	{ return d_position; }

	//Set the current mouse cursor position
	void	setPosition(const Point& position);

	//Offset the mouse cursor position by the deltas specified in \a offset.
	void	offsetPosition(const Point& offset);

	//Set the visibility of the mouse cursor.
    void    setVisible(bool visible)    {d_visible = visible;}

	//return whether the mouse cursor is visible.
	bool	isVisible(void) const	{return d_visible;}

	//return the current constraint area of the mouse cursor.
	hgeRect	getConstraintArea(void) const;

	//Set the area that the mouse cursor is constrained to.
	void	setConstraintArea(const hgeRect* area);

	//Return the current mouse cursor position as display resolution independant values.
	Point	getDisplayIndependantPosition(void) const;

    /*!
    \brief
        Function used to notify the MouseCursor of changes in the display size.

        You normally would not call this directly; rather you would call the
        function System::notifyDisplaySizeChanged and that will then call this
        function for you.

    \param new_size
        Size object describing the new display size in pixels.
    */
    void notifyDisplaySizeChanged(const Size& new_size);

protected:
	/*************************************************************************
		New event handlers
	*************************************************************************/
	//event triggered internally when image of mouse cursor changes
	virtual void	onCursorChanged(MouseCursorEventArgs& e);


private:
	/*************************************************************************
		Implementation Methods
	*************************************************************************/
	/*!
	\brief
		Checks the mouse cursor position is within the current 'constrain' hgeRect and adjusts as required.
	*/
	void	constrainPosition(void);

	/*************************************************************************
		Implementation Data
	*************************************************************************/
	// mouse cursor related
	typedef std::map<String, HCURSOR> CursorMap;
	CursorMap d_cursorRes;
	HCURSOR	d_cursorImage;		//!< Image that is currently set as the mouse cursor.

	Vector2	d_position;					//!< Current location of the cursor
	bool	d_visible;					//!< true if the cursor will be drawn, else false.
	hgeRect	d_constraints;				//!< Specifies the area (in screen pixels) that the mouse can move around in.
};

#if defined(_MSC_VER)
#	pragma warning(pop)
#endif

#endif	// end of guard _HgeMouseCursor_h_
